import { configureStore } from '@reduxjs/toolkit'
import reducers from './features/indexSlice'
import type { AppDispatch, RootState } from '@/types/store'
import { useDispatch, TypedUseSelectorHook, useSelector } from 'react-redux'
export * from './features/indexSlice' //导出slice上所有的action

// 在整个应用程序中使用，而不是简单的 `useDispatch` 和 `useSelector`,使用类型重写，省去每次传入范型
export const useAppDispatch: () => AppDispatch = useDispatch
export const useAppSelector: TypedUseSelectorHook<RootState> = useSelector

const store = configureStore({
  reducer: reducers
})

export default store
